<template>
  <div>
    <vol-box
      :lazy="true"
      :model.sync="model.box1"
      title="发送"
      :height="400"
      :width="600"
      :padding="15"
    >
      <VolForm
        :loadKey="true"
        ref="formFieldsreset"
        :formFields="formFields1"
        :formRules="formRules1"
      ></VolForm>

      <div slot="footer">
        <Button type="default" @click="submit('editFormFields')">确认</Button>
        <Button type="default" @click="model.box1 = false">关闭</Button>
      </div>
    </vol-box>
  </div>
</template>

<script>
import VolForm from "@/components/basic/VolForm.vue";
import VolBox from "@/components/basic/VolBox.vue";
import VolTable from "@/components/basic/VolTable.vue";
export default {
  components: { VolForm, VolBox, VolTable },
  data() {
    return {
      model: {
        box1: false
      },
      isXZ: "",
      url: "https://api.boss.i-town.cn/",
      formFields1: {
        title: "",
        body: "",
        tos: "",
        photo: ""
      },
      formRules1: [
        [
          {
            title: "标题",
            field: "title",
            type: "text",
            required: true,
            hidden: false
          }
        ],
        [
          {
            title: "内容",
            field: "body",
            type: "textarea",
            required: true,
            hidden: false
          }
        ],
        [
          {
            title: "收件人邮箱",
            field: "tos",
            type: "text",
            required: true,
            hidden: false
          }
        ],
        [
          {
            title: "图片路径",
            field: "photo",
            type: "text",
            hidden: true
          }
        ]
      ],
      DistributionLevelData: [],
      JsonData: []
    };
  },
  methods: {
    getOption(field) {
      let option;
      this.formRules1.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
    open6(row) {
      this.formFields1.photo = row.photo;
      this.model.box1 = true;
    },
    submit() {
      let param = {
        mainData: {
          title: this.formFields1.title,
          body: this.formFields1.body,
          tos: this.formFields1.tos,
          photo: this.formFields1.photo
        }
      };
      this.http.post("api/Mall_campphoto/SendPicture", param).then(res => {
        // console.log(param, "param");
        if (res.status) {
          this.$Message.success(res.message);
          this.$nextTick(() => {
            this.model.box1 = false;
          });
        } else {
          this.$Message.error(res.message);
        }
      });
    }
  }
};
</script>

<style></style>
<style scoped></style>
<style></style>
